function Card(contextPath,divContainer){
	View.apply(this,arguments);
	this.idField = "OID";
	this.nameField = "FIELDNAME";
	this.beforeRefresh = function(){
			return '<div class="cardstyle"><table>'+buildCardContent(this.getTitleArray(),this.getDataArray(),this.contextPath)+'</table></div>';
	};
	
	var buildCardContent = function(titleArray,dataArray,contextPath){
		var titleLength = titleArray.length;
		var dataObject = dataArray[0]||{};
		var htmlArray = ['<tr style="display:none">'];
		for(var i=0;i<titleLength;i++){
			var titleObject = titleArray[i];
			var codeValue = dataObject[titleObject.FIELDNAME]||"";
			var value = dataObject[titleObject.FIELDNAME+"TEXT"]||codeValue;
			var controlType = titleObject.CONTROLTYPE||"2";
			var cellHtml = '<td nowrap>'+titleObject.DISPLAYNAMETEXT+'</td><td><input type="text"';
			for(var ele in titleObject){
				cellHtml = cellHtml+' '+ele+'="'+titleObject[ele]+'"';
			}
			cellHtml = cellHtml+' oldValue="'+codeValue+'" codeValue="'+codeValue+'" value="'+value+'"';
			if(titleObject.FIELDTYPE=="1"){
				cellHtml = cellHtml+' class="iconinput'+controlType+'"><img src="'+contextPath+'/jsl/images/xcard/selector.gif" align="absmiddle" /></td>';
			}else if(titleObject.FIELDTYPE=="5"){
				cellHtml = cellHtml+' class="iconinput'+controlType+'"><img src="'+contextPath+'/jsl/images/xcard/calendar.gif" align="absmiddle" /></td>';
			}else{
				cellHtml = cellHtml+' class="normalinput'+controlType+'"></td>';
			}
			if(titleObject.ISHIDDEN=="1"){
				htmlArray[0] = htmlArray[0]+cellHtml;
			}else{
				if(htmlArray.length%2===1){
					htmlArray.push("</tr><tr>"+cellHtml);
				}else{
					htmlArray.push(cellHtml);
				}
			}
		}
		htmlArray.push('</tr>');
		return htmlArray.join('');
	};
}
Card.prototype = new View();
Card.prototype.submitCardValue = function(){
	var inputArray = this.divContainer.getElementsByTagName("INPUT");
	var length = inputArray.length;
	var fieldNamesArray = [];
	var condition = null;
	var action = "insert";
	var tableName = "";
	for(var i=0;i<length;i++){
		if(inputArray[i][this.nameField]==this.idField){
			if(inputArray[i].codeValue!==''){
				condition = inputArray[i][this.nameField]+" in ('"+inputArray[i].codeValue.replace(/,/g,"','")+"')";
				action = "update";
			}else{
				fieldNamesArray.push(inputArray[i][this.nameField]+"='#currentIdentity#',");
			}
			tableName = inputArray[i]["TABLENAME"];
		}else{
			fieldNamesArray.push(inputArray[i][this.nameField]+"='"+inputArray[i].codeValue+"',");
		}
	}
	fieldNamesArray.push("time"+action+"='#currentTime#',exec"+action+"=#currentUser#");
	var tempObject = new Object();
	tempObject.returnTip = "common.tip."+action+"succeed";
	var cardRequest = window["Comm"].buildRequestObject(action,fieldNamesArray.join(''),null,tableName,null,condition,null,null,null,null,tempObject);
	var cardResult = window["Comm"].sendRequest(this.contextPath,cardRequest);
	if(cardResult&&cardResult.returnTip){
		window["Comm"].showPopWindow(this.contextPath,"common.title.promptinfo",cardResult.returnTip,null,cardResult.exceptionMessage);
	}
	return cardResult;
};
Card.prototype.handleKeyUpEvent0 = function(evt){
	var handleObject = evt.srcElement;
	if(handleObject.tagName=="INPUT"&&handleObject.type=="text"&&handleObject.value!=handleObject.codeValue){
		handleObject.codeValue = handleObject.value;
	}
};
Card.prototype.handleClickEvent0 = function(evt){
	var handleObject = evt.srcElement;
	var parentObject = handleObject.parentElement;
	if(handleObject.tagName=="IMG"){
		var inputObject = parentObject.children[0];
		var fieldType = inputObject.FIELDTYPE;
		var coderDiv = window["Comm"].findDivById("specialcoderdiv");
		var divStyle = coderDiv.style;
		divStyle.left = (parentObject.getBoundingClientRect().left-1)+"px";
		divStyle.top = (inputObject.getBoundingClientRect().bottom-2)+"px";
		divStyle.width = parentObject.offsetWidth-2;
		divStyle.display = "block";
		divStyle.overflow = "auto";
		divStyle.position = "absolute";
		divStyle.border = "1px solid black";
		divStyle.backgroundColor = "white";
		coderDiv.name = "extendeddiv";
		if("1"==fieldType){
			var clickCoderTree = function(evt){
				var liObject= evt.srcElement.parentElement.parentElement;
				if(evt.srcElement.tagName=="FONT"){
					inputObject.codeValue = liObject[inputObject.REFFIELD];
					inputObject.value = liObject[inputObject.REFNAME+"TEXT"]||liObject[inputObject.REFNAME];
					divStyle.display = "none";
				}
			};
			var tempTree = new window["Tree"](this.contextPath,coderDiv);
			var queryChildren = "0 AS HASCHILDREN";
			var parentCondition = "-1";
			var parentField = inputObject.REFPARENT;
			if(parentField&&parentField!="null"&&parentField.length>0){
				queryChildren = "(SELECT COUNT(A.OID) FROM "+inputObject.REFTABLE+" A WHERE "+inputObject.REFPARENT+"="+inputObject.REFTABLE+"."+inputObject.REFFIELD+") AS HASCHILDREN";
				parentCondition = inputObject.REFPARENT;
			}
			var requestObject = window["Comm"].buildRequestObject("query",queryChildren+","+inputObject.REFFIELD+","+inputObject.REFNAME,null,inputObject.REFTABLE,null,parentCondition+"=-1",null,null,null,null);
			tempTree.dataModel = window["Comm"].sendRequest(this.contextPath,requestObject);
			tempTree.displayField = inputObject.REFNAME;
			tempTree.refresh();
			tempTree.registerEventProcessor("afterClick0",clickCoderTree);
		}else if("5"==fieldType){
			var clickTime = function(evt){
				var sourceElement = evt.srcElement;
				if(sourceElement.tagName=="TD"&&sourceElement.currentday){
					inputObject.value = sourceElement.currentday;
					inputObject.codeValue = sourceElement.currentday;
					divStyle.display = "none";
				}
			};
			var tempTime = new window["Time"](this.contextPath,coderDiv);
			tempTime.selectedDateString = inputObject.value;
			tempTime.refresh();
			tempTime.registerEventProcessor("afterClick0",clickTime);
		}else{
			window["Comm"].showPopWindow(this.contextPath,"common.title.promptinfo","common.tip.nohandleaction",null,null);
		}
		return true;
	}
};
Card.prototype.handleKeyDownEvent0 = function(evt){
	var handleObject = evt.srcElement;
	if(handleObject.tagName=="INPUT"){
		var fieldType = handleObject.FIELDTYPE;
		if("3"==fieldType&&(evt.keyCode>57||evt.keyCode<48)&&evt.keyCode!=8&&evt.keyCode!=46){
			evt.returnValue=false;
		}else if("4"==fieldType&&(evt.keyCode>57||evt.keyCode<48)&&evt.keyCode!=8&&evt.keyCode!=46&&evt.keyCode!=170){
			evt.returnValue=false;
		}
	}
};

